package com.example.androidproject.utils;

import android.util.Log;

import com.example.androidproject.app.adapter.ClassifyAdapter3;
import com.example.androidproject.movie.bean.ResultBeanData;
import com.example.androidproject.novel.bean.NovelBean;

import java.util.List;

public class RecycleViewWork {

    private final ClassifyAdapter3 rvAdpater;
    private final int classifyFlag;

    public RecycleViewWork(ClassifyAdapter3 rvAdpater, int classifyFlag) {
        this.rvAdpater = rvAdpater;
        this.classifyFlag = classifyFlag;
    }

    /**
     * 添加数据
     */
    public void addItem(int position, Object content) {
        if (classifyFlag == 1) {
        }
        rvAdpater.notifyItemInserted(position);
    }

    /**
     * 增加数据
     */
    public void insertItem(Object list) {
        if (classifyFlag == 1) {
            Log.d("GGSTUDY", "insertItem: " + list);
            List<ResultBeanData.DataBean> movielist = (List<ResultBeanData.DataBean>) list;

            rvAdpater.notifyItemRangeChanged(1, movielist.size() + 1);
//            if (ResultsConstant.MovieList == null) {
//                ResultsConstant.MovieList = new ArrayList<>();
//            } else {
////                ResultsConstant.MovieList.addAll(ResultsConstant.contentMovie);
////                rvAdpater.notifyItemInserted(ResultsConstant.MovieList.size());
//                rvAdpater.notifyItemRangeChanged(1, ResultsConstant.MovieList.size() + 1);
//            }
        }
        if (classifyFlag == 2) {
            List<NovelBean.DataBean> novellist = (List<NovelBean.DataBean>) list;
            rvAdpater.notifyItemRangeChanged(1, novellist.size() + 1);
        }
//            if (ResultsConstant.NovelList == null) {
//                ResultsConstant.NovelList = new ArrayList<>();
//            } else {
////                ResultsConstant.NovelList.addAll(ResultsConstant.contentNovel);
////                rvAdpater.notifyItemInserted(ResultsConstant.NovelList.size());
//                rvAdpater.notifyItemRangeChanged(1, ResultsConstant.NovelList.size() + 1);
//            }
//        }
    }
}
